function compareVersion(version1, version2) {
    let v1 = version1.split('.');
    let v2 = version2.split('.');
    for (let i = 0; i < v1.length || i < v2.length; i++) {
        let x = 0;
        let y = 0;
        if (i < v1.length) {
            x = parseInt(v1[i]);
        }
        if (i < v2.length) {
            y = parseInt(v2[i]);
        }
        if (x > y) return 1;
        if (x < y) return -1;
    }
    return 0;
}

console.log(compareVersion1("1.2", "1.10"));
// 版本号排序
// var data = [1.01, 1.001, 0.1, 1.1];
// data.sort(function (a, b) { return a > b ? -1 : 1; });
// console.log(data);